
Security News
OWASP 2025 Top 10 Adds Software Supply Chain Failures, Ranked Top Community Concern
OWASP’s 2025 Top 10 introduces Software Supply Chain Failures as a new category, reflecting rising concern over dependency and build system risks.
emptyfunction
Advanced tools
The module exports nothing but an empty function/closure.
npm install emptyfunction
Get the empty closure from the module
var emptyFunction = require('emptyfunction');
Now use the function whenever there is an optional closure within your code.
function example(cb) {
if (!cb) cb = emptyFunction
for (var i = 0; i < 1337; i++) cb()
}
Sometimes you might need to verify whether the closure is an empty function.
If you have access to the emptyFunction object you can do a strict comparison.
this.someFunction === emptyFunction
If not, a more hacky solution is to use the name of the function:
this.someFunction.name === 'emptyFunction'
A simple function to check whether we're dealing with an actual closure:
function isClosure(cb) {
return (cb && cb !== emptyFunction) ? true: false
}
A simple function to make assigning closures easier:
function setClosure(cb) {
return (isClosure(cb)) ? cb : emptyFunction
}
// Usage:
var myClosure = setClosure(cb)
MIT
FAQs
An empty function.
The npm package emptyfunction receives a total of 346 weekly downloads. As such, emptyfunction popularity was classified as not popular.
We found that emptyfunction demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
OWASP’s 2025 Top 10 introduces Software Supply Chain Failures as a new category, reflecting rising concern over dependency and build system risks.

Research
/Security News
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.

Security News
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.